//
//  SecondViewController.m
//  Photo
//
//  Created by dllo on 15/11/5.
//  Copyright (c) 2015年 Zebra. All rights reserved.
//

#import "SecondViewController.h"

@interface SecondViewController ()<UIScrollViewDelegate>

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    

    NSLog(@"OOOOO");
    


    



    
    

    
    

    

   
    
    
    
    
    
    
    
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor brownColor];
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 64)];
    [self.view addSubview:scrollView];
    scrollView.tag = 100;
    [scrollView release];
    for (int i = 1; i < 10; i++) {
        UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake((i - 1) * self.view.bounds.size.width, 0, scrollView.bounds.size.width, scrollView.bounds.size.height )];
        NSString *str = [NSString stringWithFormat:@"%d.jpg", i];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, scrollView.bounds.size.width, scrollView.bounds.size.height)];
        imageView.image = [UIImage imageNamed:str];
        [scroll addSubview:imageView];
        scroll.delegate = self;
        scroll.minimumZoomScale = 0.5;
        scroll.maximumZoomScale = 2.0;
        [imageView release];
        [scrollView addSubview:scroll];
        [scroll release];
    }
    
    
    
    
    
    
    
    
    // Do any additional setup after loading the view.
}







- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    UIView *view = [scrollView.subviews firstObject];
    return view;
}

- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
    UIImageView *imageView = (UIImageView *)[scrollView.subviews firstObject];
    UIScrollView *scroll = (UIScrollView *)[self.view viewWithTag:100];
    imageView.center = scroll.center;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
